package cn.tedu.dimanage.pojo.dto;

import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * @Classname: UserAddNewDTO
 * @Author: bromide
 * @CreateTime: 2022/6/10--11:44
 * @Version: V1.0
 * @Description:
 */
@Data
public class UserAddNewDTO implements Serializable {

    @NotNull(message = "添加用户失败,请提交用户名!")
    @Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9_]{3,15}$" ,message = "用户名必须以字母开头,且长度在4-15")
    @Pattern(regexp = "[^\\s]{1,}",message = "用户名不能包含空格")
    private String username;

    @NotNull(message = "添加用户失败,请提交密码!")
    @Pattern(regexp = "[^\\s]{1,}",message = "密码不能包含空格")
    private String password;

    @NotNull(message = "添加用户失败,请提交真实姓名!")
    private String name;

    // todo 增加身份证的正则
    @NotNull(message = "添加用户失败,请提交身份证号码!")
    @Pattern(regexp = "^[1-9]\\d{5}(18|19|20|(3\\d))\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$",message = "请输入正确的身份证号码")
    private String idNumber;

    @NotNull(message = "添加用户失败,请提交年龄!")
    //@Pattern(regexp = "^((1[0-5])|[1-9])?\\d$",message = "无效的年龄,请重新输入!")
    @Max(value = 120,message = "无效的年龄,请重新输入!")
    @Min(value = 0,message = "无效的年龄,请重新输入!")
    private Integer age;

    @NotNull(message = "添加用户失败,请提交手机号码!")
    @Pattern(regexp = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$", message = "请输入正确的手机号码")
    private String phone;

    @NotNull(message = "添加用户失败,请提交邮箱号码!")
    @Pattern(regexp ="^(\\w+([-.][A-Za-z0-9]+)*){3,18}@\\w+([-.][A-Za-z0-9]+)*\\.\\w+([-.][A-Za-z0-9]+)*$" ,message = "请输入正确的邮箱号码")
    private String email;

    private String avatar;

}
